package com.zretc.controller;

import com.github.pagehelper.PageInfo;
import com.zretc.entity.VipOrders;
import com.zretc.service.BackVipOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping("/back")
public class BackVipOrdersController {

    @Autowired
    private BackVipOrdersService backVipOrdersService;


    @PostMapping("vipOrdersInfo")
    @ResponseBody
    int insertVipOrdersInfo(String accountId,String vipTypeId,String vipOrdersPrice){

        VipOrders vipOrders = new VipOrders();
        Integer newAccountId = Integer.valueOf(accountId);
        vipOrders.setAccountId(newAccountId);
        vipOrders.setVipTypeId(vipTypeId);

        vipOrders.setVipOrdersPrice(vipOrdersPrice);

    int insertVipOrdersInfo = backVipOrdersService.insertVipOrdersInfo(vipOrders);

     return insertVipOrdersInfo;
    }

/*
    @GetMapping("vipOrdersInfo")
    @ResponseBody
    PageInfo<VipOrders> getVipOrdersInfoByVipOrdersId(String VipOrdersId,String page,String limit){

    PageInfo<VipOrders> getVipOrdersInfoByVipOrdersId = backVipOrdersService.getVipOrdersInfoByVipOrdersId(VipOrdersId,page,limit );

    return getVipOrdersInfoByVipOrdersId;

    }*/

    @RequestMapping("vipOrdersInfo")
    @ResponseBody
    PageInfo<VipOrders> getAllInfo(String page,String limit){

        PageInfo<VipOrders> getAllInfo = backVipOrdersService.getAllVipOrdersInfo(page,limit);
        return getAllInfo;

    }

}
